package com.lanqiaofinal11;

/**
 * @author `RKC`
 * @date 2022/6/17 10:07
 */
public class D本质上升序列 {

    private static final int N = 210;
    private static String s = "tocyjkdzcieoiodfpbgcncsrjbhmugdnojjddhllnofawllbhfiadgdcdjstemphmnjihecoapdjjrprrqnhgccevdarufmliqijgihhfgdcmxvicfauachlifhafpdccfseflcdgjncadfclvfmadvrnaaahahndsikzssoywakgnfjjaihtniptwoulxbaeqkqhfwl";//a b ab
    //f[i]表示以第i个字符结尾的本质上升序列个数
    private static int[] f = new int[N];
    private static int n = s.length();

    public static void main(String[] args) {
        for (int i = 0; i < N; i++) f[i] = 1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < i; j++) {
                if (s.charAt(i) > s.charAt(j)) f[i] += f[j];
                else if (s.charAt(i) == s.charAt(j)) f[i] -= f[j];
            }
        }
        long ans = 0;
        for (int i = 0; i < n; i++) ans += f[i];
        System.out.println(ans);
    }

    private static int get(char c) {
        return c - 'a';
    }
}
